<?php

class Admin_Form_User extends Zend_Form
{

    public function init()
    {
        $fullname = new Zend_Form_Element_Text("user_fullname");
        $fullname->setLabel("Họ & Tên")
            ->removeDecorator("HtmlTag");
        
        $gender = new Zend_Form_Element_Select("user_gender");
        $gender->setLabel("Giới Tính")
            ->removeDecorator("HtmlTag")
            ->setRequired(true);
            $gender->addMultiOptions(array(
                    "Nam" => "Nam",
                    "Nữ"  => "Nữ",
            ));
            
        $image = new Zend_Form_Element_File('user_image');
        $image->setDestination(APPLICATION_PATH .'/../public/default/images/user/')
                ->setLabel('Ảnh đại diện')
                ->addValidator('Size', false, 1024000)
                ->addValidator('Extension', false, 'jpg, ico, jpeg, png')
                ->setMaxFileSize(1024000)
                ->removeDecorator("HtmlTag");
        
        $email = new Zend_Form_Element_Text("user_email");
        $email->setLabel("Email (*)")
            ->setRequired(true)
            ->removeDecorator("HtmlTag")
            ->addFilters(array(
                    "StringTrim",
                    "StripTags",
            ))
            ->addValidator("EmailAddress", TRUE);
        
        $pass = new Zend_Form_Element_Password("password");
        $pass->setRequired(TRUE)
            ->setLabel("Mật khẩu (*)")
            ->addFilters(array(
                    "StringTrim",
                    "StripTags",
            ))
            ->removeDecorator("HtmlTag");
        
        $repass = new Zend_Form_Element_Password("repassword");
        $repass->setRequired(TRUE)
                ->setLabel("Nhập lại mật khẩu")
                ->addFilters(array(
                        "StringTrim",
                        "StripTags",
                ))
                ->removeDecorator("HtmlTag");
        $role = new Zend_Form_Element_Select('user_role');
        $role->setLabel('Quyền truy cập (*)')
            ->removeDecorator("HtmlTag")
            ->setRequired(true);
        $role->addMultiOptions(array(
                ''=>'Chọn quyền truy cập',
                'admin'=>'Admin',
                'member'=>'Khách',
        ));
         
        $address = new Zend_Form_Element_Text("user_address");
        $address->setLabel("Địa Chỉ")
            ->removeDecorator("HtmlTag");
        
        $phone = new Zend_Form_Element_Text("user_phone");
        $phone->setLabel("Số Điện Thoại")
                ->removeDecorator("HtmlTag")
                ->addFilter("Alnum");
        
        $submit = new Zend_Form_Element_Submit("add");
        $submit->setLabel("Thêm")
            ->removeDecorator("DtDdWrapper");
        $this->addElements(array($fullname, $email, $gender, $pass, $repass, $address, $phone, $role, $image,  $submit));
    }


}

